package com.example.demo.Controller;
import com.example.demo.common.AppResult;
import com.example.demo.model.Board;
import com.example.demo.services.IBoardService;
import io.swagger.annotations.Api;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;


@Slf4j
@Api(tags = "板块接口")
@RestController
@RequestMapping("/board")
public class BoardController {

    @Value("${czq-forum.index.board-num:9}")
    private Integer indexBoardNum;

    @Resource
    private IBoardService boardService;

    //查询首页板块列表
    @RequestMapping("/topList")
    public AppResult<List<Board>> topList(){
        log.info("首页板块数为：indexBoardNum=", indexBoardNum);

        //查询首页板块列表
        List<Board> boards=boardService.selectByNum(indexBoardNum);
        if(boards==null){
            boards=new ArrayList<>();
        }

        return AppResult.success(boards);
    }

}
